package com.sykj.qianxuezhan.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.sykj.qianxuezhan.bean.NurseType;
import com.sykj.qianxuezhan.server.NurseTypeService;
import com.sykj.util.reponse.CommonEnum;
import com.sykj.util.reponse.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 * @Author QianXuezhan
 * @Date 2020/7/19 15:36
 * @Description: TODO
 */
@CrossOrigin
@RestController
@RequestMapping("/nurse_type")
public class NurseTypeController {
    @Autowired
    private NurseTypeService  nurseTypeService;
    /**
    * @Description:  查询所有综合查询s
    **/
    @RequestMapping(value="/queryNurseType",method = RequestMethod.GET)
    public List<NurseType> queryNurseType(String typeName){
        System.out.println(typeName);
        return  nurseTypeService.queryNurseType(typeName);
    }

    /**
    * @Description:  添加护理类型信息
    **/
    @RequestMapping("/addNurseType")
    public ResultBody addNurseType(String  typeName,Long  sortNo,String  typeRemark) throws ParseException {
        System.out.println(typeName+"-------------------------");
        NurseType nurseType=new NurseType();
        nurseType.setTypeName(typeName);
        nurseType.setSortNo(sortNo);
        nurseType.setTypeRemark(typeRemark);
         nurseTypeService.addNurseType(nurseType);
        return  new ResultBody();
    }

    @RequestMapping("/updateNurseType")
    public ResultBody  updateNurseType(String  typeId,String  typeName,Long  sortNo,String  typeRemark){
        UpdateWrapper queryWrapper=new  UpdateWrapper();
        queryWrapper.eq("type_id",typeId);
        queryWrapper.set("type_name",typeName);
        queryWrapper.set("sort_no",sortNo);
        queryWrapper.set("type_remark",typeRemark);
        nurseTypeService.update(queryWrapper);
        return  new ResultBody(CommonEnum.SUCCESS);
    }
}
